package com.cloud.bc.controller.common;

import com.cloud.bc.controller.BaseController;
import com.cloud.bc.model.entity.BcAbouts;
import com.cloud.bc.model.enums.AboutEnum;
import com.cloud.bc.service.BcAboutsService;
import com.cloud.bc.util.BcUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@AllArgsConstructor
@RequestMapping("common/about")
public class AboutController extends BaseController {

    private final BcAboutsService bcAboutsService;
    private final BcUtils bcUtils;

    /**
     * 协议
     */
    @GetMapping("agreement")
    public ModelAndView agreement(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.AGREEMENT.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("title", AboutEnum.AGREEMENT.getDesc());
        view.addObject("data", bcAboutsResult);
        return view;
    }

    /**
     * 联系我们
     */
    @GetMapping("contact")
    public ModelAndView contact(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.CONTACT.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.CONTACT.getDesc());
        return view;
    }

    /**
     * 关于我们
     */
    @GetMapping("introduction")
    public ModelAndView introduction(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.INTRODUCTION.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.INTRODUCTION.getDesc());
        return view;
    }

    /**
     * 充值协议
     */
    @GetMapping("rechargeagreement")
    public ModelAndView rechargeagreement(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.RECHARGEAGREEMENT.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.RECHARGEAGREEMENT.getDesc());
        return view;
    }

    /**
     * VIP会员说明
     */
    @GetMapping("vipexplain")
    public ModelAndView vipexplain(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.VIPEXPLAIN.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.VIPEXPLAIN.getDesc());
        return view;
    }

    /**
     * VIP会员购买协议
     */
    @GetMapping("vipagreement")
    public ModelAndView vipagreement(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.VIPAGREEMENT.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.VIPAGREEMENT.getDesc());
        return view;
    }

    /**
     * 提现说明
     */
    @GetMapping("withdrawalexplain")
    public ModelAndView withdrawalexplain(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.WITHDRAWALEXPLAIN.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.WITHDRAWALEXPLAIN.getDesc());
        return view;
    }

    /**
     * 分享说明
     */
    @GetMapping("marketingexplain")
    public ModelAndView marketingexplain(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.MARKETINGEXPLAIN.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.MARKETINGEXPLAIN.getDesc());
        return view;
    }

    /**
     * 分享说明
     */
    @GetMapping("paymentagreement")
    public ModelAndView paymentagreement(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.PAYMENTAGREEMENT.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.PAYMENTAGREEMENT.getDesc());
        return view;
    }

    /**
     * 帮助
     */
    @GetMapping("help")
    public ModelAndView help(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.HELP.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.HELP.getDesc());
        return view;
    }
    /**
     * 兑换说明
     */
    @GetMapping("exchangeexplain")
    public ModelAndView exchangeexplain(HttpServletRequest request, HttpServletResponse response) {
        BcAbouts bcAbouts = new BcAbouts();
        bcAbouts.setId(AboutEnum.EXCHANGEEXPLAIN.getCode());
        BcAbouts bcAboutsResult = bcAboutsService.selectOne(bcAbouts);
        ModelAndView view = baseView(request, bcAboutsResult.getTitle(), bcUtils.gotoView(request, "about/index"));
        view.addObject("data", bcAboutsResult);
        view.addObject("title", AboutEnum.EXCHANGEEXPLAIN.getDesc());
        return view;
    }
}
